/*
 * 		Author : Xerxes
 * 		Program: 
 * 		Created On : 30.09.2011 20:07:00 BDT
 *      "I have not failed, I have just found 10000 ways that won't work.
 * 
*/


#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>

#include <ctime>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;

#define VI vector< int >
#define CI( x ) scanf("%d",&x)
#define CL( x ) scanf("%lld",&x)
#define CD( x ) scanf("%lf",&x )
#define fo(i,st,ed) for(int i = st ; i < ed ; ++i )
#define foE(i,st,ed) for(int i = st ; i <= ed ; ++i )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define f first
#define s second
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )
#define tp pair< int, pair<int,int> >
#define mmk( x, y , z ) mk( x, mk( y, z ) )

inline void wait( double seconds ){
    double endtime = clock()+( seconds* CLOCKS_PER_SEC );
    while( clock() < endtime ){
        ;
    }
}
int R,C,S;
char command;
char g[101][101];

int sr,sc,dir;
		 // D = turn 90 right
		 // E = turn 90 left
		 // F = move forward
		  //  N  S  L  O
		  //  N  S, E  W
int dir1[4] = {0, 1, 2, 3};
int   D1[4] = {2, 3, 1, 0};
int   E1[4] = {3, 2, 0, 1};
int FM1[4][2] = { {-1,0}, {+1,0},{0,+1},{0,-1}  };

inline void Read(){
		fo(i,0,R){
			fo(j,0,C){
				cin>>g[i][j];
			}
		}
			
		fo(i,0,R){
			fo(j,0,C){
				char ch = g[i][j];
				if( ch=='N' ){
					sr = i;
					sc = j;
					dir = 0;
					return ;
				}
				if( ch=='S' ){
					sr = i;
					sc = j;
					dir = 1;
					return ;
				}
				if( ch=='L' ){
					sr = i;
					sc = j;
					dir = 2;
					return ;
				}
				if( ch=='O' ){
					sr = i;
					sc = j;
					dir = 3;
					return ;
				}
				
			}
		}
}

inline int recur(int _r, int _c, int _dir, int indx){
	if( indx== S ){
		return 0;
	}
	cin>>command;
	
	int res=0;	
	fo(i,0,4){
		if( _dir == dir1[i] ){
			if( command=='F' ){
					int tr = _r+FM1[i][0];
					int tc = _c+FM1[i][1];
					if( tr<0 || tc<0 || tr>=R || tc>=C ){
						res = recur(_r,_c,_dir,indx+1);
					}
					else if( g[tr][tc]=='#' ){
						res = recur(_r,_c,_dir,indx+1);
					}
					else if( g[tr][tc]=='*'){
						g[tr][tc]='.';
						res = 1+recur(tr,tc,_dir,indx+1);
					}
					else{
						res = recur(tr,tc,_dir,indx+1);
					}
			}
			else if( command=='D' ){
				res = recur(_r,_c,D1[i],indx+1);
			}
			else if( command=='E' ){
				res = recur(_r,_c,E1[i],indx+1);
			}
			else{
				res = 0;
			}
				
		}
	}
	return res;
}
inline void Proc(){
	
	int var = recur(sr,sc,dir,0);
	cout<<var<<"\n";
	
}

int main(){
    #ifndef ONLINE_JUDGE
        freopen("in","rt",stdin);
    #endif
		
		while( scanf("%d %d %d",&R,&C,&S) == 3 ){
			if( R==0 && C==0 && S==0 )break;
			Read();
			Proc();
		}

return 0;
}


